using System;
using System.Collections.Generic;

using AjaxPro;

namespace ECCIT
{
    [Serializable]
    public enum SortOrderType
    {
        Asc = 0,
        Desc = 1,
    }

    [Serializable]
    public class SortOrderPair
    {
        private SortOrderType _key;
        private string _value;

        public SortOrderType Key
        {
            get { return _key; }
            set { _key = value; }
        }

        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        private SortOrderPair(SortOrderType key, string value)
        {
            _key = key;
            _value = value;
        }

        public static SortOrderPair CreateInstance(SortOrderType key, string value)
        {
            return new SortOrderPair(key, value);
        }

        public SortOrderPair() { }
    }

    [Serializable]
    public class SortOrder
    {
        public static SortOrderPair Asc = SortOrderPair.CreateInstance(SortOrderType.Asc, "ASC");
        public static SortOrderPair Desc = SortOrderPair.CreateInstance(SortOrderType.Desc, "DESC");
    }

	[Serializable()]
	public class SortingParameter
	{
		private string _sortExpression;
        private SortOrderPair _sortOrder;
		
		public string SortExpression
		{
			get{ return _sortExpression; }
			set{ _sortExpression = value; }
		}

        public SortOrderPair SortOrder
		{
			get{ return _sortOrder; }
			set{ _sortOrder = value; }
		}

		public SortingParameter(){}

        public SortingParameter(string sortExpression, SortOrderPair sortOrder)
		{
			_sortExpression = sortExpression;
			_sortOrder = sortOrder;
		}
	}

    public class SortingParameterFactory
    {
        public static SortingParameter CreateInstance(string sortExpr, SortOrderPair sortOrder)
        {
            return new SortingParameter(sortExpr, sortOrder);
        }

        public static SortingParameter CreateNonSortingParameter()
        {
            return new SortingParameter(string.Empty, SortOrder.Desc);
        }
    }
}
